package fhp.hlhj.giantfold.customView

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.TextView

import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.interfaces.YesListener
import fhp.hlhj.giantfold.utils.MyUtils
import kotlinx.android.synthetic.main.confrimdialog.*

/**
 * Created by FHP on 2017/8/4.
 */

class ConfirmDialog(context: Context) : Dialog(context, R.style.CustomDialog) {
    private lateinit var yesListener: YesListener
    private val TAG = "info"
    private var flag = 0

    fun setYesListener(yesListener: YesListener) {
        this.yesListener = yesListener
    }


    override fun onCreate(savedInstanceState: Bundle) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.confrimdialog)

        btYes.setOnClickListener {
            if (flag == 0) {
                MyUtils.toast("未设置flag")
            } else {
                yesListener.yes(flag)
                dismiss()
            }
        }

    }

    fun setTitle(str: String) {
        tvTitle.text = str
    }

    fun setFlag(flag: Int) {
        this.flag = flag
    }

}
